home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / MPW_TOOL / TOOLS / TOOLS_WI / ICON_8 / TESTS / ENDETAB.ICN < prev    next >
Text File  |  1990-03-02  |  1KB  |  36 lines

  1. # test type conversion and error handling in entab/detab
  2.  
  3. procedure main ()
  4.    s := "rutabaga"
  5.    if entab('1987') ~== "1789" then write ("oops 1")
  6.    if detab('1492') ~== "1249" then write ("oops 2")
  7.    if entab("    ","3") ~== "\t\t" then write ("oops 3")
  8.    if detab("\t\t","3") ~== "    " then write ("oops 4")
  9.    ferr (103, entab, [])
  10.    ferr (103, detab, [])
  11.    ferr (103, entab, [[]])
  12.    ferr (103, detab, [[]])
  13.    ferr (101, entab, [s,2,3,&lcase])
  14.    ferr (101, detab, [s,4,5,&ucase])
  15.    ferr (210, entab, [s,7,4])
  16.    ferr (210, entab, [s,6,6])
  17.    ferr (210, detab, [s,8,5])
  18.    ferr (210, detab, [s,3,3])
  19.    end
  20.  
  21.  
  22. # ferr(err,func,arglst) -- call func(args), verify that error "err" is produced
  23.  
  24. procedure ferr (err, func, args)
  25.    msg := "oops -- " || image(func) || "(" || image (val) || ") "
  26.    &error := 1
  27.    if func!args
  28.       then write (msg, "succeeded")
  29.    else if &error ~= 0
  30.       then write (msg, "failed but no error")
  31.    else if &errornumber ~= err
  32.       then write (msg, "got error ",&errornumber," instead of ",err)
  33.    &error := 0
  34.    return
  35.    end
  36.